package com.craney.testMask
{
	import flash.display.Bitmap;
	import flash.display.Loader;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.filters.BitmapFilterQuality;
	import flash.filters.BlurFilter;
	import flash.geom.ColorTransform;
	import flash.net.URLRequest;
	import flash.ui.Mouse;
	
	public class TestMask
	{
		private var myBitmap:Bitmap;
		
		private var parentSprite:Sprite;
		
		private var circleMask:Sprite;
		
		public function TestMask(sp:Sprite)
		{
			parentSprite = sp;
			initMask();
			startLoadImg();
//			Mouse.hide();
		}

		private function loaded(evt:Event):void
		{
			myBitmap = evt.target.content as Bitmap;
			parentSprite.addChild(myBitmap);
			myBitmap.cacheAsBitmap = true;
			myBitmap.mask = circleMask;
			
		}
		
		private function initMask():void
		{
			circleMask = new Sprite();
			circleMask.graphics.beginFill(0xffff00);
			circleMask.graphics.drawCircle(0, 0, 60);
			circleMask.graphics.endFill();
			circleMask.filters = [new BlurFilter(20, 20, BitmapFilterQuality.HIGH)];
			circleMask.cacheAsBitmap = true;
			parentSprite.addChild(circleMask);
			circleMask.startDrag(true);
		}
		
		private function startLoadImg():void
		{
			var loader:Loader = new Loader();
			var request:URLRequest = new URLRequest("earth.jpg");
			loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaded);
			loader.load(request);
		}

	}
}